package com.eagle.rate.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.eagle.rate.service.TaobaoRateService;
import com.taobao.com.Util;

public class PermissionAction extends BaseAction {
	@Autowired
	private TaobaoRateService taobaoRateService;
	private static final Log _log = LogFactory.getLog(PermissionAction.class);

	/**
	 * @todo 授权验证
	 * @return
	 * @throws Exception
	 */
	public String checkAuth() throws Exception {
		HttpServletRequest request = getRequest();
		try {
			String top_parameters = request.getParameter("topParams");
			String nick = Util.ParametersName(top_parameters);
			String topSession = request.getParameter("topSession");
			_log.debug("nick================================" + nick);
			_log.debug("topSession================================"
					+ topSession);
			HttpSession session = request.getSession(true);
			session.setAttribute("nick", nick);
			//这里做用香袭怡人做测试
			session.setAttribute("nick", "香袭怡人");
			session.setAttribute("topSession", topSession);
		    int innerPermission = 	taobaoRateService.checkNick(nick, topSession);
				session.setAttribute("innerPermission", innerPermission);	//内部应用访问标识
				return INDEX;
		} catch (Exception e) {
			return AUTH;
		}
	}
	

	
	
}